package unit3;

import java.util.Scanner;

public class Retirement2 {
	public static void main(String[] args) {
//		read inputs
		@SuppressWarnings("resource")
		Scanner s=new Scanner(System.in);
//		System.out.println("How much money do you need to retire?");
//		double goal=s.nextDouble();
		
		System.out.println("How much money will you contirbute every year?");
		double payment=s.nextDouble();
		
		System.out.println("Interest rate in %:");
		double interestRate=s.nextDouble();
		
		double balance=0;
		int year=0;
		
		String input;
		
//		update account balance while user isn't ready to retire 
		do {
//			add this year's payment and interest 
			balance+=payment;
			double interest=balance*interestRate/100;
			balance+=interest;
			
			year++;
			
//			print current balance
			System.out.printf("After year %d,you balance is %,.2f%n",year ,balance);
			
//			ask if ready to retire and get input
			System.out.print("Ready to retire ?(Y/N)");
			input=s.next();	
		} while ("N".equals(input));
	}
}
